package com.tju.resource.tool.tool;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则表达式
 *
 * @USER: CLS
 */
public class RegExp {

    /**
     * 提前字符串中的IP地址
     *
     * @param ipString
     * @return
     */
    public static String getIps(String ipString) throws Exception {
        String regEx = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
        String ips = null;
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(ipString);
        while (m.find()) {
            ips = m.group();
        }
        return ips;
    }

}
